$(document).ready(function(){
$('.dataTables_length').css("display", "none");
$(".save_txt").click(function(){
var ID=$(this).attr('id');
var description = $("#des_input_"+ID).val();
var youtube_id = $("#ytb_input_"+ID).val();
	if (description != "" || youtube_id != "" ) {
		$.ajax({
		url: baseurl + "admin_home/edit",
		type: "post",
		data:{'youtube_id':youtube_id,'description':description,'ID':ID},
		success: function(str){
			var string = $.parseJSON(str);
				if (string.success == false) {
					alert(string.reason);
				}else{
						$("#des_"+ID).text(description);
						$("#"+ID+" .value > a").attr("href", "http://www.youtube.com/watch?v="+string.id);
						$("#"+ID+" .value > a > img").attr("src", "http://i1.ytimg.com/vi/"+string.id+"/maxresdefault.jpg");
						$("#"+ID+" .value > a > p").text(string.id);
						$("#"+ID+" .edit_txt").toggle();
						$("#"+ID+" .save_txt").toggle();
						$("#"+ID+" .cancel_txt").toggle();
						$("#"+ID+" .value").toggle();
						$("#"+ID+" .input").toggle();
				}
		},
			error: function(str){alert('Error!! Please contact the administrator.');}
		});
		}else{
				alert('Please enter both description and youtube_id');
		}
});
});
